import httpRequest from "@/utils/http-request.js";


/**
 * 新增
 * @param name
 * @param code
 * @param sysDictItemList
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const add = (
    {
        name,
        code,
        sysDictItemList
    }
) => {
    return httpRequest.post("/sys/dict", {
        name,
        code,
        sysDictItemList
    });
}

/**
 * 根据ID删除
 * @param id
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deleteById = (id) => {
    return httpRequest.delete(`/sys/dict/${id}`);
}


/**
 * 编辑
 * @param id
 * @param name
 * @param code
 * @param sysDictItemList
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const modifyById = (
    id,
    {
        name,
        code,
        sysDictItemList
    }
) => {
    return httpRequest.put(`/sys/dict/${id}`, {
        name,
        code,
        sysDictItemList
    });
}

/**
 * 详情
 * @param id
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const detailById = (id) => {
    return httpRequest.get(`/sys/dict/detail/${id}`);
}

/**
 * 分页查询
 * @param page
 * @param size
 * @returns {*}
 */
export const page = (page, size) => {
    return httpRequest.get(`/sys/dict/page/${page}/${size}`);
}
/**
 * 加载所有
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const all = () => {
    return httpRequest.get("/sys/dict/list");
}

